/*
 * @Author: 'zhangkeqq' '2211709169@qq.com'
 * @Date: 2025-07-25 17:54:13
 * @LastEditors: 'zhangkeqq' '2211709169@qq.com'
 * @LastEditTime: 2025-07-30 15:31:24
 * @FilePath: \vue3-admin-node\vue3-admin\src\api\userinfo\index.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import instance from '@/http/index'
import type {bindFormData,passwordFormData,nameFormData,
    sexFormData,emailFormData,createAdminFormData,changeIdentityToAdminForm,searchUserForm,banHotUserForm,adminListForm
} from './type'
//统一管理接口
enum API{
    USERINFO_URL = '/user/getUserInfo',
    BINDACCOUNT_URL = '/user/bindAccount',
    CHANGEPASSWORD_URL = '/user/changePassword',
    CHANGENAME_URL = '/user/changeName',
    CHANGESEX_URL = '/user/changeSex',
    CHANGEEMAIL_URL = '/user/changeEmail',
    //--------------------------用户管理
    CREATEADMIN_URL = '/user/createAdmin',
    GETADMINLIST_URL = '/user/getAdminList',
    EDITADMIN_URL = '/user/editAdmin',
    CHANGEIDENTITYTOUSER_URL = '/user/changeIdentityToUser',
    CHANGEIDENTITYTOADMIN_URL = '/user/changeIdentityToAdmin',
    SEARCHUSER_URL = '/user/searchUser',
    SEARCHUSERBYDEPARTMENT_URL = '/user/searchUserByDepartment',
    BANHOTUSER_URL = '/user/banHotUser',
    GETBANLIST_URL = '/user/getBanList',
    DELETEUSER_URL = '/user/deleteUser',
}

//获取用户信息
export const getUserInfo = (id:null| string)=>{
    return instance.post(API.USERINFO_URL,{id})
}
//绑定图片地址跟账号
export const bind = (data:bindFormData)=>{
    return instance.post(API.BINDACCOUNT_URL,data)

}
//修改密码
export const changePassword = (data:passwordFormData)=>{
    return instance.post(API.CHANGEPASSWORD_URL,data)
}
//修改姓名
export const changeName = (data:nameFormData)=>{
    return instance.post(API.CHANGENAME_URL,data)
}
//修改性别
export const changeSex = (data:sexFormData)=>{
    return instance.post(API.CHANGESEX_URL,data)
}
//修改邮箱
export const changeEmail = (data:emailFormData)=>{
    return instance.post(API.CHANGEEMAIL_URL,data)
}


// ----------------------------------------用户管理
// 添加管理员
export const createAdmin = (data:createAdminFormData)=>{
    return instance.post(API.CREATEADMIN_URL,data)
}
// 获取管理员列表
export const getAdminList = (data:adminListForm)=>{
    return instance.post(API.GETADMINLIST_URL,data)
}
//编辑管理员账号信息
export const editAdmin = (data:createAdminFormData)=>{
    return instance.post(API.EDITADMIN_URL,data)
}
//对管理员取消赋权
export const changeIdentityToUser = (id:string)=>{
    return instance.post(API.CHANGEIDENTITYTOUSER_URL,{id})
}
//对用户进行赋权 
export const changeIdentityToAdmin = (data:changeIdentityToAdminForm)=>{
    return instance.post(API.CHANGEIDENTITYTOADMIN_URL,data)
}
//通过账号对用户搜索
export const searchUser = (data:searchUserForm)=>{
    return instance.post(API.SEARCHUSER_URL,data)
}
//通过部门对用户搜索
export const searchUserByDepartment = (department:string)=>{
    return instance.post(API.SEARCHUSERBYDEPARTMENT_URL,{department})
}
//冻结账号/解冻账号
export const banHotUser = (data:banHotUserForm)=>{
    return instance.post(API.BANHOTUSER_URL,data)
}
//获取冻结用户列表
export const getBanList = ()=>{
    return instance.post(API.GETBANLIST_URL)
}
//删除用户id
export const deleteUser = (id:number)=>{
    return instance.post(API.DELETEUSER_URL,{id})
}